import {useState} from "react";
import A from "./A";
import './index.css';
import {MyContext} from "./MyContext";

export const Demo = () => {
	const {Provider} = MyContext;
	const [theme, setTheme] = useState("light");
	return (
		<div className="parent">
			<button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>
				切换主题
			</button>
			<h3>我是Demo组件,当前主题是: {theme}</h3>
			<Provider value={theme}>
				<A />
			</Provider>
		</div>
	)
}